package com.netty.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.netty.admin.mapper.FriendMapper;
import com.netty.admin.mapper.UserMapper;
import com.netty.admin.security.service.TokenService;
import com.netty.admin.service.FriendService;
import com.netty.admin.service.UserService;
import com.netty.common.entity.Friend;
import com.netty.common.entity.User;
import com.netty.common.entity.result.Result;
import com.netty.common.entity.vo.LoginUser;
import com.netty.common.util.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @author LiuXiaoYu
 * @date 2022/2/1- 13:33
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private TokenService tokenService;
    /** 根据token
     * 获取用户个人信息
     * @return
     */
    @Override
    public Result<?> getUserInfo(HttpServletRequest request) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        if (Objects.nonNull(loginUser)){
            return Result.success(loginUser.getUser());
        }
        return Result.success();
    }
}
